package com.example.springboot.controller;

import com.example.springboot.util.Result;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：晋升（js20020923@qq.com）
 * @date ：Created in 2023/1/31 20:03
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@CrossOrigin
public class MyController {

//    @GetMapping("getData")
//    public Result getData1(){
//        return new Result("hello");
//    }


    //后台转递给前台数据的时候 格式统一
    @GetMapping("getData")
    //只接受前台传递过来的get请求
    public Result getData(){
        Map<String,String> map = new HashMap<>();
        map.put("date","2016-05-02");
        map.put("name","王小虎999999999999999999999");
        map.put("province","上海");
        map.put("city","普陀区");
        map.put("address","上海市普陀区金沙江路 1518 弄");
        map.put("zip","200333");


        Map<String,String> map2 = new HashMap<>();
        map2.put("date","2016-05-02");
        map2.put("name","王小虎");
        map2.put("province","上海");
        map2.put("city","普陀区");
        map2.put("address","上海市普陀区金沙江路 1518 弄");
        map2.put("zip","200333");

        Map<String,String> map3 = new HashMap<>();
        map3.put("date","2016-05-02");
        map3.put("name","王小虎");
        map3.put("province","上海");
        map3.put("city","普陀区");
        map3.put("address","上海市普陀区金沙江路 1518 弄");
        map3.put("zip","200333");

        Map<String,String> map4 = new HashMap<>();
        map4.put("date","2016-05-02");
        map4.put("name","王小虎");
        map4.put("province","上海");
        map4.put("city","普陀区");
        map4.put("address","上海市普陀区金沙江路 1518 弄");
        map4.put("zip","200333");

        Map<String,String> map5 = new HashMap<>();
        map5.put("date","2016-05-02");
        map5.put("name","王小虎");
        map5.put("province","上海");
        map5.put("city","普陀区");
        map5.put("address","上海市普陀区金沙江路 1518 弄");
        map5.put("zip","200333");
        List<Map> list = new ArrayList<>();
        list.add(map);
        list.add(map2);
        list.add(map3);
        list.add(map4);
        list.add(map5);
        return new Result(list);
    }
}

